package c.x.jy.service.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.Query;

import c.x.jy.dao.dao.StudiesDao;
import c.x.jy.dao.entity.StudiesEntity;
import c.x.jy.service.service.StudiesService;
import org.apache.commons.lang3.StringUtils;


@Service("studiesService")
public class StudiesServiceImpl extends ServiceImpl<StudiesDao, StudiesEntity> implements StudiesService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        	QueryWrapper<StudiesEntity> query= 	 new QueryWrapper<StudiesEntity>() ;
    	if(params.get("searchKey")!=null&&params.get("searchValue")!=null&&!StringUtils.isEmpty(params.get("searchKey").toString())&&!StringUtils.isEmpty(params.get("searchValue").toString()))
    	    query.eq(  params.get("searchKey").toString(), params.get("searchValue"));

        IPage<StudiesEntity> page = this.page(
                new Query<StudiesEntity>().getPage(params),
                 query
        );

        return new PageUtils(page);
    }

    @Override
    public List<StudiesEntity> all() {
        List<StudiesEntity> list = this.baseMapper.all();
        return list;
    }
}
